<?php
class createService extends service {
	function __construct($id_reporter) {
		parent::__construct($id_reporter);
		$this->set('reportes','estado',1);
	}

	public function create() {
		$arrDatos = $this->data['reportes'];
		$arr_keys = array_keys($arrDatos);
		$values = "";
		$keys = "";
		$query = "INSERT INTO reportes";
		for ($i = 0; $i < count($arr_keys);$i++) {
			$keys .=$arr_keys[$i].",";
			if (is_string($arrDatos[$arr_keys[$i]])) {	$values .= "'".$arrDatos[$arr_keys[$i]]."',"; }
			else { $values .= $arrDatos[$arr_keys[$i]].","; }
		}
		$keys = substr($keys,0,strlen($keys)-1);
		$values = substr($values,0,strlen($values)-1);
		$query .= "(".$keys.") VALUES (".$values.");";
		try {
			mysql_query($query);
			if (1000 < mysql_errno() && mysql_errno() < 2056) throw new Exception("Error al intentar insertar datos en reporte.");
			else return mysql_insert_id();
		} catch (Exception $e) {
			echo mysql_errno(). " : " .mysql_error();
			return false;
		}
	}
}
?>